#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

void test01()
{
	for (int i = 3; i <= 100; i += 3)
	{
		printf("%d ", i);
	}
}

void swap(int* x, int* y)
{
	int tmp = *x;
	*x = *y;
	*y = tmp;
}

void test02()
{
	int a = 0;
	int b = 0;
	int c = 0;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b)
		swap(&a, &b);
	if (a < c)
		swap(&a, &c);
	if (b < c)
		swap(&b, &c);
	printf("%d %d %d", a, b, c);
	
	
}

void test03()
{
	for (int i = 100; i <= 200; i++)
	{
		int flag = 0;
		for (int j = 2; j < i; j++)
		{
			if (i % j == 0)
				flag = 1;
		}
		if (flag == 0)
			printf("%d ", i);
	}
}

void test04()
{
	for (int i = 1000; i <= 2000; i++)
	{
		if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
			printf("%d ", i);
	}
}

void test05()
{
	int a = 0;
	int b = 0;
	scanf("%d %d", &a, &b);
	for (int i = a; i >= 1; i--)
	{
		if (b % i == 0 && a % i == 0)
		{
			printf("%d", i);
			break;
		}
	}
}

int main()
{
	//test01();
	//test02();
	//test03();
	//test04();
	test05();
	return 0;
}